#pragma once

#include <algorithm>


typedef struct _BMP{
    _BMP(): width(0),height(0),data(NULL) {};       // default constructor
    _BMP(const _BMP& bmp_)                          // copy constructor
    {
        (*this) = bmp_;
    }
    ~_BMP() {if(data) delete[] data; data=NULL;};   // destructor
    _BMP& operator = (const _BMP& bmp_)             // assignment operator
    {
        width = bmp_.width;
        height = bmp_.height;
        if (bmp_.data)                              // if data in bmp, do deep copy
        {
            data = new unsigned char[4*bmp_.width*bmp_.height];
            std::copy( bmp_.data, bmp_.data + 4*bmp_.width*bmp_.height, data );
        }
        else
            data = NULL;        

        return (*this);
    };


    int width;
    int height;
    unsigned char* data;
} BMP;

BMP ReadBmpImage( const char *filename, unsigned char r, unsigned char g, unsigned char b, bool alpha = false );